home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-13 / ncu_edit.zip / EDIT.ASM < prev    next >
Assembly Source File  |  1992-12-06  |  50KB  |  1,837 lines

  1. ;=========================================================
  2. ; Author: Chen Jean-Yuan         NCU-MIS 2A     No.790854
  3. ;=========================================================
  4.  
  5. extrn     display_:near
  6. extrn     ins_line:near
  7. extrn     del_line:near
  8. extrn     put_buff:near
  9. extrn     get_buff:near
  10. extrn     find_ptr:near
  11. extrn     load_act:near
  12. extrn     save_act:near
  13. extrn     write_act:near
  14. extrn     print_act:near
  15. extrn     newing:near
  16. extrn     help_win:near
  17. extrn     chg_drive:near
  18. extrn     p_ptr:word
  19. extrn     q_ptr:word
  20. extrn     r_ptr:word
  21. extrn     free_top:word
  22. extrn     free_ptr:word
  23. extrn     line_buf:byte
  24. extrn     block_top:word
  25. extrn     block_end:word
  26.  
  27. public    info_win,refresh_,new_act,here_dir,read_line,show_name
  28. public    new_start,new_end,total_l,top_,bottom_,y_table,monitor,cursor_y
  29. public    file_top,file_ptr,file_name,handle_,this_dir
  30. public    psp_start
  31.  
  32. space     equ      20h
  33. color1    equ      07h
  34. color2    equ      02h
  35. color3    equ      07h
  36. reverse1  equ      70h
  37. reverse2  equ      70h
  38. reverse3  equ      70h
  39. escape    equ      1                    ;-----+
  40. enter_s   equ      28                   ;     |
  41. f10       equ      68                   ;     |
  42. f1        equ      59                   ;     |
  43. f2        equ      60                   ;     |
  44. f3        equ      61                   ;     |
  45. pgup      equ      73                   ;     |
  46. pgdn      equ      81                   ;     |
  47. ctrl_pgup equ      132                  ;     |
  48. ctrl_pgdn equ      118                  ;     |
  49. up        equ      72                   ;     |
  50. left      equ      75                   ;     |
  51. right     equ      77                   ; Scan Code
  52. down      equ      80                   ;     |
  53. inskey    equ      82                   ;     |
  54. delkey    equ      83                   ;     |
  55. homekey   equ      71                   ;     |
  56. endkey    equ      79                   ;     |
  57. d_key     equ      32                   ;     |
  58. o_key     equ      24                   ;     |
  59. m_key     equ      50                   ;     |
  60. b_key     equ      48                   ;     |
  61. k_key     equ      37                   ;     |
  62. h_key     equ      35                   ;     |
  63. p_key     equ      25                   ;     |
  64. n_key     equ      49                   ;     |
  65. y_key     equ      21                   ;-----+
  66.  
  67. backspace equ      8                    ;-----+
  68. escape_a  equ      27                   ; ASCII Code
  69. enter_a   equ      13                   ;-----+
  70.  
  71. win_max   equ      4
  72. file_max  equ      6
  73. utl_max   equ      5
  74. block_max equ      7
  75.  
  76. GET_CHAR  MACRO
  77.           push     ax
  78.           pushf
  79.           mov      ah,0
  80.           int      16h
  81.           mov      char,ah
  82.           popf
  83.           pop      ax
  84.           ENDM
  85.  
  86. GET_KEY   MACRO
  87.           push     ax
  88.           pushf
  89.           mov      ah,0
  90.           int      16h
  91.           mov      scan_key,ah
  92.           mov      ascii_key,al
  93.           popf
  94.           pop      ax
  95.           ENDM
  96.  
  97. NEW_      MACRO                         ;AX register save the Segment
  98.           LOCAL    over_z,exist_
  99.           push     es
  100.           push     bx
  101.           cmp      free_top,0
  102.           jne      exist_
  103.  
  104.           add      new_end,2
  105.           mov      ax,new_end
  106.           jmp      over_z
  107.  
  108.   exist_: mov      ax,free_top
  109.           mov      es,ax
  110.           mov      bx,es:[0]
  111.           mov      free_top,bx
  112.   over_z: pop      bx
  113.           pop      es
  114.           ENDM
  115.  
  116. FREE_     MACRO    _ptr
  117.           LOCAL    n_empt,free_z
  118.           push     es
  119.           pushf
  120.           mov      ax,_ptr
  121.           cmp      free_top,0
  122.           jne      n_empt
  123.           mov      free_top,ax
  124.           jmp      free_z
  125.  
  126.   n_empt: mov      es,free_ptr
  127.           mov      es:[0],ax
  128.   free_z: mov      free_ptr,ax
  129.           mov      es,ax
  130.           mov      word ptr es:[0],0
  131.           popf
  132.           pop      es
  133.           ENDM
  134.  
  135. GOTOXY    MACRO    x,y
  136.           mov      dh,y
  137.           mov      dl,x
  138.           inc      dh
  139.           dec      dl
  140.           mov      bh,0
  141.           mov      ah,2
  142.           int      10h
  143.           ENDM
  144.  
  145. CURSOR_1  MACRO
  146.           push     cx
  147.           mov      ch,0bh
  148.           mov      cl,0ch
  149.           mov      ah,1
  150.           int      10h
  151.           pop      cx
  152.           ENDM
  153.  
  154. CURSOR_0  MACRO
  155.           push     cx
  156.           mov      ch,1ch
  157.           mov      cl,1bh
  158.           mov      ah,1
  159.           int      10h
  160.           pop      cx
  161.           ENDM
  162.  
  163. data      segment  public
  164. top_      db 0,0,24,'===== Top of File ======'
  165.           db 5 dup(0)
  166. bottom_   db 0,0,24,'==== Bottom of File ===='
  167.           db 5 dup(0)
  168. monitor   dw ?
  169. win_x     dw ?
  170. win_y     dw ?
  171. cursor_x  dw ?
  172. cursor_y  dw ?
  173. total_l   dw ?
  174. psp_start dw ?
  175. new_start dw ?
  176. new_end   dw ?
  177. pos_x     db ?
  178. pos_y     db ?
  179. col_start dw ?
  180. p_lin     dw ?
  181. q_lin     dw ?
  182. r_lin     dw ?
  183. file_top  dw ?
  184. file_ptr  dw ?
  185. file_name db 'NONAME.DOC',3 dup(0)
  186. this_dir  db 80 dup(0)
  187. handle_   dw ?
  188. char      db ?
  189. scan_key  db ?
  190. ascii_key db ?
  191. info_key  db ?
  192. ins_flag  db ?
  193. sub_line  db 256 dup(?)
  194. y_table   dw    0, 160, 320, 480, 640, 800, 960,1120,1280,1440,1600,1760,1920
  195.           dw 2080,2240,2400,2560,2720,2880,3040,3200,3360,3520,3680,3840
  196. win_head  db '    File     Edit     Utility     Block '
  197.           db '           ░▒▓ NCU MIS-2A  No.790854 ▓▒░'
  198. edit_head db '═══════════════════════════════════╡ Edi'
  199.           db 'tor ╞═════════════════════════════'
  200. ins_fun   db                                   '══════'
  201. ins_val   db                                   'Insert'
  202. win_info  db ' F1-Help  F2-Save  F3-Load  F10-Menu    '  ;----+
  203.           db '     ║ Total '                             ;    |
  204.   str_ttl db              '     '                        ;    |
  205. win_info2 db                   ' │ Line '                ;  Info
  206.   str_y   db                           '     '           ;    |
  207. win_info3 db                                ' Col '      ;    |
  208.   str_x   db                                     '    '  ;----+
  209. win_file  db 15,8,color2
  210.           db '┌─────────────╖'
  211.           db '│ Load     F3 ║'
  212.           db '│ Save     F2 ║'
  213.           db '│ Write to    ║'
  214.           db '│ New         ║'
  215.           db '│ OS Shell    ║'
  216.           db '│ Exit        ║'
  217.           db '╘═════════════╝'
  218. win_utl   db 20,7,color2
  219.           db '┌──────────────────╖'
  220.           db '│ Help          F1 ║'
  221.           db '│ Change Drive     ║'
  222.           db '│ Time & Date      ║'
  223.           db '│ Print File       ║'
  224.           db '│ Lock Terminal    ║'
  225.           db '╘══════════════════╝'
  226. win_block db 30,9,color2
  227.           db '┌────────────────────────────╖'
  228.           db '│ Set Begin     Shift-Ctrl-B ║'
  229.           db '│ Set End       Shift-Ctrl-K ║'
  230.           db '│ Copy Block    Shift-Ctrl-O ║'
  231.           db '│ Delete Block  Shift-Ctrl-D ║'
  232.           db '│ Move Block    Shift-Ctrl-M ║'
  233.           db '│ Hide Block    Shift-Ctrl-H ║'
  234.           db '│ Print Block   Shift-Ctrl-P ║'
  235.           db '╘════════════════════════════╝'
  236. good_bye  db 'Thanks for Using this Editor !!! $'
  237. data      ends
  238. ;---------------------------------------
  239. code      segment  public
  240.           assume   cs:code,ds:data,ss:stack
  241.  
  242. main      proc     far
  243.           org      100h
  244.  
  245.   start:  push     ds
  246.           mov      ax,data
  247.           mov      ds,ax
  248.  
  249.           pop      ax
  250.           mov      psp_start,ax         ;Save PSP addr. of Segment
  251.  
  252.           mov      ax,sp
  253.           mov      cl,4
  254.           shr      ax,cl
  255.           mov      cx,ss
  256.           add      ax,cx
  257.           inc      ax
  258.           mov      new_start,ax
  259.           mov      new_end,ax
  260.  
  261.           int      11h                  ;Initalize Monitor Type
  262.           and      al,00110000b
  263.           cmp      al,00110000b
  264.           mov      monitor,0B000h       ;Mono
  265.           je       over_s
  266.           add      monitor,800h         ;Color
  267.   over_s:
  268.           mov      al,0                 ;Clear Screen
  269.           mov      ch,2
  270.           mov      cl,0
  271.           mov      dh,22
  272.           mov      dl,79
  273.           mov      bh,07
  274.           mov      ah,6
  275.           int      10h
  276.           mov      win_x,1              ;Initialize New Values
  277.           mov      cursor_x,1
  278.           mov      cursor_y,1
  279.           mov      total_l,1
  280.           mov      col_start,1
  281.           mov      pos_x,1
  282.           mov      pos_y,2
  283.           mov      block_top,1
  284.           mov      block_end,1
  285.           mov      free_top,0
  286.           mov      ins_flag,0
  287.  
  288.           NEW_
  289.           mov      word ptr top_,ax
  290.           mov      ax,seg top_
  291.           add      ax,2
  292.           push     es
  293.           mov      es,word ptr top_
  294.           mov      es:[0],ax
  295.           mov      byte ptr es:[2],0
  296.           mov      word ptr es:[30],0
  297.           pop      es
  298.  
  299.           call     here_dir
  300.           call     title_win
  301.           call     info_win
  302.           call     show_name
  303.           GOTOXY   pos_x,pos_y
  304.           mov      ax,0
  305.           push     ax
  306.           mov      ax,1
  307.           push     ax
  308.           call     display_
  309.  
  310.   get_c:  GET_KEY
  311.           xor      ax,ax                ;If Shift-Ctrl Both pressed
  312.           mov      es,ax
  313.           mov      al,es:[417h]
  314.           and      al,00000111b
  315.           cmp      al,4
  316.           jbe      chk_k
  317.           call     s_c_key
  318.           jmp      get_c
  319.  
  320.   chk_k:  cmp      ascii_key,0
  321.           je       key_0
  322.           cmp      ascii_key,224
  323.           je       key_0
  324.           jmp      comm_
  325.   key_0:  cmp      scan_key,f10         ;F10 pressed
  326.           jne      key_1
  327.           call     windows
  328.           jmp      get_c
  329.   key_1:  cmp      scan_key,up          ;Up-Arrow pressed
  330.           jne      key_2
  331.           cmp      cursor_y,1
  332.           je       no_ch1
  333.           dec      cursor_y
  334.           call     info_win
  335.           cmp      pos_y,1
  336.           je       st_ch1
  337.           dec      pos_y
  338.           GOTOXY   pos_x,pos_y
  339.           jmp      get_c
  340.  
  341.   st_ch1: call     refresh_
  342.           jmp      get_c
  343.  
  344.   no_ch1: mov      pos_y,2
  345.           GOTOXY   pos_x,pos_y
  346.           call     refresh_
  347.           jmp      get_c
  348.  
  349.   key_2:  cmp      scan_key,down        ;Down-Arrow pressed
  350.           jne      key_3
  351.           mov      ax,total_l
  352.           cmp      cursor_y,ax
  353.           je       no_ch2
  354.           inc      cursor_y
  355.           call     info_win
  356.           cmp      pos_y,21
  357.           je       st_ch2
  358.           inc      pos_y
  359.           GOTOXY   pos_x,pos_y
  360.           jmp      get_c
  361.  
  362.   st_ch2: call     refresh_
  363.           jmp      get_c
  364.  
  365.   no_ch2: cmp      total_l,20
  366.           jae      mor_20
  367.           jmp      get_c
  368.   mor_20: mov      pos_y,20
  369.           GOTOXY   pos_x,pos_y
  370.           call     refresh_
  371.           jmp      get_c
  372.  
  373.   key_3:  cmp      scan_key,left        ;Left-Arrow pressed
  374.           jne      key_4
  375.           cmp      cursor_x,1
  376.           je       no_ch3
  377.           dec      cursor_x
  378.           call     info_win
  379.           cmp      pos_x,1
  380.           je       st_ch3
  381.           dec      pos_x
  382.           GOTOXY   pos_x,pos_y
  383.           jmp      st__3
  384.  
  385.   st_ch3: dec      col_start
  386.   st__3:  call     refresh_
  387.  
  388.   no_ch3: jmp      get_c
  389.  
  390.   key_4:  cmp      scan_key,right       ;Right-Arrow pressed
  391.           jne      key_5
  392.           cmp      cursor_x,256
  393.           je       no_ch4
  394.           inc      cursor_x
  395.           call     info_win
  396.           cmp      pos_x,80
  397.           je       st_ch4
  398.           inc      pos_x
  399.           GOTOXY   pos_x,pos_y
  400.           jmp      no_ch4
  401.  
  402.   st_ch4: inc      col_start
  403.           call     refresh_
  404.  
  405.   no_ch4: jmp      get_c
  406.  
  407.   key_5:  cmp      scan_key,delkey      ;Delete Key pressed
  408.           jne      key_6
  409.           mov      ax,cursor_y
  410.           push     ax
  411.           call     find_ptr
  412.           call     put_buff             ;Put Linked-List in Line-Buffer
  413.           mov      ax,cursor_x
  414.           dec      ax
  415.           cmp      line_buf,al
  416.           ja       shf_d1
  417.           mov      ax,cursor_y
  418.           inc      ax
  419.           cmp      ax,total_l
  420.           jae      no_del               ;No Act at Last 2 Line
  421.           call     extra_del
  422.   no_del: jmp      get_c
  423.  
  424.   shf_d1: xor      cx,cx
  425.           mov      cl,line_buf
  426.           mov      di,offset line_buf
  427.           add      di,ax
  428.           sub      cx,ax
  429.   shf_d2: inc      di
  430.           mov      al,[di+1]
  431.           mov      [di],al
  432.           loop     shf_d2
  433.           dec      line_buf
  434.           call     get_buff
  435.           call     refresh_
  436.           jmp      get_c
  437.  
  438.   key_6:  cmp      scan_key,homekey     ;Home Key pressed
  439.           jne      key_7
  440.           mov      pos_x,1
  441.           GOTOXY   pos_x,pos_y
  442.           mov      cursor_x,1
  443.           call     info_win
  444.           mov      col_start,1
  445.           call     refresh_
  446.           jmp      get_c
  447.  
  448.   key_7:  cmp      scan_key,endkey       ;End Key pressed
  449.           jne      key_8
  450.           mov      ax,cursor_y
  451.           push     ax
  452.           call     find_ptr
  453.           call     put_buff
  454.           xor      ax,ax
  455.           mov      al,line_buf
  456.           mov      cursor_x,ax
  457.           inc      cursor_x
  458.           call     info_win
  459.           cmp      line_buf,78
  460.           ja       at_80
  461.           mov      pos_x,al
  462.           inc      pos_x
  463.           GOTOXY   pos_x,pos_y
  464.           mov      col_start,1
  465.           call     refresh_
  466.           jmp      get_c
  467.  
  468.   at_80:  mov      pos_x,80
  469.           push     ax
  470.           GOTOXY   pos_x,pos_y
  471.           pop      ax
  472.           sub      ax,78
  473.           mov      col_start,ax
  474.           call     refresh_
  475.           jmp      get_c
  476.  
  477.   key_8:  cmp      scan_key,inskey      ;Insert Key pressed
  478.           jne      key_9
  479.           mov      di,offset ins_fun
  480.           cmp      ins_flag,0
  481.           je       inson
  482.           mov      cx,6
  483.   insoff: mov      byte ptr [di],'═'
  484.           inc      di
  485.           loop     insoff
  486.           mov      ins_flag,0
  487.           call     title_win
  488.           jmp      get_c
  489.  
  490.   inson:  mov      si,offset ins_val
  491.           mov      ax,seg ins_fun
  492.           mov      es,ax
  493.           cld
  494.           mov      cx,6
  495.   rep     movsb
  496.           mov      ins_flag,1
  497.           call     title_win
  498.           jmp      get_c
  499.  
  500.   key_9:  cmp      scan_key,f3          ;F3 Key pressed
  501.           jne      key_10
  502.           call     load_act
  503.           call     refresh_
  504.           call     info_win
  505.           GOTOXY   pos_x,pos_y
  506.           jmp      get_c
  507.  
  508.   key_10: cmp      scan_key,f2          ;F2 Key pressed
  509.           jne      key_11
  510.           mov      ax,offset this_dir[1]
  511.           push     ax
  512.           call     save_act
  513.           call     refresh_
  514.           jmp      get_c
  515.  
  516.   key_11: cmp      scan_key,pgup        ;Page Up
  517.           jne      key_12
  518.           mov      ax,cursor_y
  519.           xor      ch,ch
  520.           mov      cl,pos_y
  521.           sub      ax,cx
  522.           cmp      ax,20
  523.           jg       sub_20
  524.           cmp      cursor_y,20
  525.           ja       su__20
  526.           mov      pos_y,2
  527.           mov      cursor_y,1
  528.           GOTOXY   pos_x,pos_y
  529.           jmp      pg_up
  530.  
  531.   su__20: add      cx,ax
  532.           sub      cx,20
  533.           mov      pos_y,cl
  534.           GOTOXY   pos_x,pos_y
  535.   sub_20: sub      cursor_y,20
  536.   pg_up:  call     refresh_
  537.           call     info_win
  538.           jmp      get_c
  539.  
  540.   key_12: cmp      scan_key,pgdn        ;Page Down
  541.           jne      key_13
  542.  
  543.   no_ct2: mov      ax,total_l
  544.           sub      ax,cursor_y
  545.           cmp      ax,20
  546.           ja       add_20
  547.           mov      pos_y,1
  548.           mov      ax,total_l
  549.           mov      cursor_y,ax
  550.           GOTOXY   pos_x,pos_y
  551.           jmp      pg_up
  552.  
  553.   add_20: add      cursor_y,20
  554.   pg_dn:  call     refresh_
  555.           call     info_win
  556.           jmp      get_c
  557.  
  558.   key_13: cmp      scan_key,f1          ;F1 Key pressed
  559.           jne      key_14
  560.           call     help_win
  561.           call     refresh_
  562.           jmp      get_c
  563.  
  564.   key_14: cmp      scan_key,ctrl_pgup   ;Control-Page Up
  565.           jne      key_15
  566.           mov      pos_y,2
  567.           mov      cursor_y,1
  568.           GOTOXY   pos_x,pos_y
  569.           call     refresh_
  570.           call     info_win
  571.  
  572.   key_15: cmp      scan_key,ctrl_pgdn   ;Control-Page Down
  573.           jne      key_16
  574.           mov      ax,total_l
  575.           mov      cursor_y,ax
  576.           cmp      ax,20
  577.           jb       at_20
  578.           mov      al,20
  579.   at_20:  mov      pos_y,al
  580.           GOTOXY   pos_x,pos_y
  581.           call     refresh_
  582.           call     info_win
  583.  
  584.   key_16: jmp      get_c
  585.  
  586.   comm_:  mov      ax,cursor_y
  587.           push     ax
  588.           call     find_ptr
  589.           call     put_buff             ;Key in a Character
  590.           cmp      ascii_key,backspace  ;BackSpace Key pressed
  591.           jne      comm_1
  592.  
  593.           mov      ax,cursor_x
  594.           cmp      ax,1
  595.           jne      con_
  596.           jmp      get_c
  597.  
  598.   con_:   dec      ax
  599.           cmp      line_buf,al
  600.           ja       shf_l1
  601.           jb       same_l
  602.           dec      line_buf
  603.           call     get_buff
  604.   same_l: mov      scan_key,left
  605.           jmp      key_3
  606.  
  607.   shf_l1: xor      cx,cx
  608.           mov      cl,line_buf
  609.           mov      di,offset line_buf
  610.           add      di,ax
  611.           sub      cx,ax
  612.   shf_l2: mov      al,[di+1]
  613.           mov      [di],al
  614.           inc      di
  615.           loop     shf_l2
  616.           dec      line_buf
  617.           call     get_buff
  618.           jmp      same_l
  619.  
  620.   comm_1: cmp      ascii_key,enter_a    ;Enter Key pressed
  621.           je       _13h
  622.           jmp      comm_2
  623.   _13h:   mov      pos_x,1
  624.           mov      col_start,1
  625.           cmp      ins_flag,1
  626.           je       ins_li
  627.  
  628.           mov      ax,total_l
  629.           cmp      cursor_y,ax
  630.           je       eq_hom
  631.           mov      cursor_x,1
  632.           inc      cursor_y
  633.           cmp      pos_y,21
  634.           je       sc_up1
  635.           inc      pos_y
  636.   sc_up1: GOTOXY   pos_x,pos_y
  637.           call     info_win
  638.           call     refresh_
  639.           jmp      get_c
  640.  
  641.   eq_hom: mov      scan_key,homekey
  642.           jmp      key_6
  643.  
  644.   ins_li: inc      cursor_y
  645.           mov      ax,cursor_x
  646.           dec      ax
  647.           mov      cursor_x,1
  648.           cmp      line_buf,al
  649.           ja       cut_l
  650.           cmp      pos_y,21
  651.           je       sc_up2
  652.           inc      pos_y
  653.   sc_up2: GOTOXY   pos_x,pos_y
  654.           call     ins_line
  655.           call     refresh_
  656.           jmp      get_c
  657.  
  658.   cut_l:  xor      cx,cx                ;Cut This Line to be 2 Parts
  659.           mov      cl,line_buf
  660.           mov      line_buf,al
  661.           sub      cl,al
  662.           mov      sub_line,cl
  663.           mov      bx,seg sub_line
  664.           mov      es,bx
  665.           mov      di,offset sub_line+1
  666.           mov      si,offset line_buf
  667.           add      si,ax
  668.           inc      si
  669.           cld
  670.   rep     movsb
  671.           NEW_                          ;===== Insert 1 Line =====
  672.           mov      es,r_ptr             ;P_ptr^.next:=NEW_ptr
  673.           mov      es:[0],ax
  674.           mov      es,ax
  675.           mov      ax,p_ptr             ;NEW_ptr^.next:=P_ptr
  676.           mov      es:[0],ax
  677.           mov      byte ptr es:[2],0
  678.           mov      word ptr es:[30],0
  679.           mov      p_ptr,es
  680.           inc      total_l
  681.           call     info_win
  682.           call     get_buff
  683.           mov      es,p_ptr
  684.           mov      ax,es:[0]
  685.           mov      p_ptr,ax
  686.           cmp      pos_y,21
  687.           je       sc_up3
  688.           inc      pos_y
  689.   sc_up3: GOTOXY   pos_x,pos_y
  690.           xor      cx,cx
  691.           mov      cl,sub_line
  692.           inc      cx
  693.           mov      bx,seg line_buf
  694.           mov      es,bx
  695.           mov      di,offset line_buf
  696.           mov      si,offset sub_line
  697.           cld
  698.   rep     movsb
  699.           call     get_buff
  700.           call     refresh_
  701.           jmp      get_c
  702.  
  703.   comm_2: cmp      ascii_key,escape_a   ;ESC Key pressed
  704.           jne      comm_3
  705.           jmp      get_c
  706.  
  707.   comm_3: cmp      cursor_x,256         ;Common Key
  708.           jne      ok_
  709.           jmp      get_c
  710.  
  711.   ok_:    mov      di,offset line_buf
  712.           xor      ax,ax
  713.           mov      al,line_buf
  714.           mov      cx,cursor_x
  715.           dec      cx
  716.           cmp      cl,line_buf
  717.           ja       add_bk
  718.  
  719.           inc      cx
  720.           cmp      cl,line_buf
  721.           jbe      no_lng
  722.           mov      line_buf,cl
  723.           add      di,cx
  724.           mov      al,ascii_key
  725.           mov      [di],al
  726.           jmp      p_link
  727.  
  728.   no_lng: add      di,cx
  729.           cmp      ins_flag,0
  730.           je       no_ins
  731.  
  732.           cmp      line_buf,255
  733.           je       key_in
  734.  
  735.           xor      ax,ax
  736.           mov      al,line_buf
  737.           neg      cx
  738.           add      cx,ax
  739.           inc      cx
  740.           mov      si,di
  741.           add      si,cx
  742.   shf_r:  mov      al,[si-1]
  743.           mov      [si],al
  744.           dec      si
  745.           loop     shf_r
  746.           inc      line_buf
  747.  
  748.   no_ins: mov      al,ascii_key
  749.           mov      [di],al
  750.           jmp      p_link
  751.  
  752.   add_bk: add      di,ax
  753.           sub      cl,line_buf
  754.   put_s:  inc      di
  755.           mov      byte ptr [di],' '
  756.           loop     put_s
  757.           mov      ax,cursor_x
  758.           mov      line_buf,al
  759.           mov      al,ascii_key
  760.           mov      [di+1],al
  761.  
  762.   p_link: call     get_buff
  763.           inc      cursor_x
  764.           call     info_win
  765.           cmp      pos_x,80
  766.           je       scro_
  767.           inc      pos_x
  768.           GOTOXY   pos_x,pos_y
  769.           jmp      one_ch
  770.  
  771.   scro_:  inc      col_start
  772.   one_ch: call     refresh_
  773.  
  774.   key_in: jmp      get_c
  775.  
  776. main      endp
  777.  
  778. refresh_  proc     near
  779.           mov      ax,cursor_y
  780.           xor      bx,bx
  781.           mov      bl,pos_y
  782.           sub      ax,bx
  783.           inc      ax
  784.           push     ax
  785.           mov      ax,col_start
  786.           push     ax
  787.           call     display_
  788. refresh_  endp
  789.  
  790. title_win proc     near                 ;Display Title
  791.           push     es
  792.           push     ax
  793.           push     cx
  794.           pushf
  795.  
  796.           mov      es,monitor
  797.           cld
  798.           mov      si,offset win_head
  799.           mov      di,0
  800.           mov      al,color1
  801.           mov      cx,80
  802.   loop_w: movsb
  803.           stosb
  804.           loop     loop_w
  805.  
  806.           mov      si,offset edit_head
  807.           mov      di,y_table+2
  808.           mov      al,color1
  809.           mov      cx,80
  810.   loop_e: movsb
  811.           stosb
  812.           loop     loop_e
  813.           mov      di,y_table[2]
  814.           mov      cx,6
  815.           add      di,75
  816.   b__ed:  mov      byte ptr es:[di],0fh
  817.           add      di,2
  818.           loop     b__ed
  819.  
  820.           popf
  821.           pop      cx
  822.           pop      ax
  823.           pop      es
  824.           ret
  825. title_win endp
  826.  
  827. info_win  proc     near
  828.           push     ax
  829.           push     cx
  830.           push     di
  831.           push     si
  832.           push     es
  833.  
  834.           call     itoa_3
  835.           mov      ax,offset str_y
  836.           push     ax
  837.           push     cursor_y
  838.           call     itoa_5
  839.           mov      ax,offset str_ttl
  840.           push     ax
  841.           push     total_l
  842.           call     itoa_5
  843.  
  844.           cld
  845.           mov      es,monitor
  846.           mov      di,y_table[46]
  847.           mov      cx,80
  848.           mov      si,offset win_info
  849.           mov      al,reverse2
  850.   loop_i: movsb
  851.           stosb
  852.           loop     loop_i
  853.  
  854.           pop      es
  855.           pop      si
  856.           pop      di
  857.           pop      cx
  858.           pop      ax
  859.           ret
  860. info_win  endp
  861.  
  862. windows   proc     near                 ;********************
  863.           push     ax                   ;* Windows Function *
  864.           push     cx                   ;********************
  865.           CURSOR_0
  866.  
  867.           mov      char,0
  868.   sel_:   call     title_win            ;Refresh Screen
  869.           call     refresh_
  870.  
  871.           mov      win_y,1
  872.           cmp      char,f10
  873.           je       exit_w
  874.  
  875.           cmp      win_x,1              ;File Window
  876.           jne      srn1
  877.           call     file_win
  878.           jmp      sel_
  879.   srn1:   cmp      win_x,2              ;Edit Window
  880.           jne      srn2
  881.           call     edit_win
  882.           jmp      sel_
  883.   srn2:   cmp      win_x,3              ;Utility Window
  884.           jne      srn3
  885.           call     utl_win
  886.           jmp      sel_
  887.   srn3:   call     block_win            ;Block Window
  888.           jmp      sel_
  889.  
  890.   exit_w: GOTOXY   pos_x,pos_y
  891.           CURSOR_1
  892.           pop      cx
  893.           pop      ax
  894.           ret
  895. windows   endp
  896.  
  897. file_win  proc     near                 ;+------+
  898.           push     ax                   ;| File |
  899.           push     bx                   ;+------+
  900.           push     cx
  901.           push     es
  902.           push     si
  903.           push     di
  904.  
  905.           mov      es,monitor
  906.           mov      cx,6                 ;[File] be reversed
  907.           mov      di,7
  908.           mov      al,reverse1
  909.   f_6:    mov      es:[di],al
  910.           add      di,2
  911.           loop     f_6
  912.  
  913.           cld
  914.   draw_f: mov      si,offset win_file+3 ;Draw File Window
  915.           xor      cx,cx
  916.           mov      cl,win_file+1
  917.           xor      bx,bx
  918.   loopf2: mov      di,y_table[bx+2]
  919.           add      bx,2
  920.           add      di,4
  921.           push     cx
  922.           pushf
  923.           xor      cx,cx
  924.           mov      al,win_file+2
  925.           mov      cl,win_file
  926.   loopf1: movsb
  927.           stosb
  928.           loop     loopf1
  929.  
  930.           popf
  931.           pop      cx
  932.           loop     loopf2
  933.  
  934.           mov      bx,win_y             ;Mark Selection
  935.           shl      bx,1
  936.           mov      di,y_table[bx+2]
  937.           add      di,7
  938.           xor      cx,cx
  939.           mov      cl,win_file
  940.           sub      cl,2
  941.           mov      al,reverse3
  942.   rev_f:  mov      es:[di],al
  943.           add      di,2
  944.           loop     rev_f
  945.  
  946.   get_f:  GET_CHAR
  947.           call     l_or_r               ;If Left or Right
  948.           cmp      al,0
  949.           je       n_r_l
  950.           jmp      end_f
  951.   n_r_l:  mov      ax,file_max
  952.           push     ax                   ;If Up or Down
  953.           call     u_or_d
  954.           cmp      al,0
  955.           je       key_f
  956.           jmp      draw_f
  957.   key_f:  cmp      char,f10
  958.           jne      n_f10
  959.           jmp      end_f
  960.   n_f10:  cmp      char,escape
  961.           jne      nextf1
  962.           mov      char,f10
  963.           jmp      end_f
  964.   nextf1: cmp      char,enter_s
  965.           je       chk_y
  966.           jmp      get_f
  967.  
  968.   chk_y:  cmp      win_y,1              ;LOAD
  969.           jne      chk_y2
  970.           call     load_act
  971.           call     refresh_
  972.           call     info_win
  973.           GOTOXY   pos_x,pos_y
  974.           mov      char,f10
  975.           jmp      end_f
  976.  
  977.   chk_y2: cmp      win_y,2              ;SAVE
  978.           jne      chk_y3
  979.           mov      ax,offset this_dir[1]
  980.           push     ax
  981.           call     save_act
  982.           call     refresh_
  983.           mov      char,f10
  984.           jmp      end_f
  985.  
  986.   chk_y3: cmp      win_y,3              ;Write to
  987.           jne      chk_y4
  988.           CURSOR_1
  989.           call     write_act
  990.           CURSOR_0
  991.           jmp      end_f
  992.  
  993.   chk_y4: cmp      win_y,4              ;New
  994.           jne      chk_y5
  995.           call     new_act
  996.           jmp      end_f
  997.  
  998.   chk_y5: cmp      win_y,5
  999.           jne      chk_y6
  1000. ;          call     os_shell
  1001.           mov      char,f10
  1002.           jmp      end_f
  1003.  
  1004.   chk_y6: CURSOR_1                      ;Exit to DOS
  1005.           mov      al,0
  1006.           xor      cx,cx
  1007.           mov      dx,184fh
  1008.           mov      bh,07
  1009.           mov      ah,6
  1010.           int      10h
  1011.           mov      dx,offset good_bye
  1012.           mov      ah,09h
  1013.           int      21h
  1014.           mov      ah,4ch
  1015.           int      21h
  1016.  
  1017.   end_f:  pop      di
  1018.           pop      si
  1019.           pop      es
  1020.           pop      cx
  1021.           pop      bx
  1022.           pop      ax
  1023.           ret
  1024. file_win  endp
  1025.  
  1026. new_act   proc     near
  1027.           call     newing
  1028.           mov      total_l,1
  1029.           mov      cursor_x,1
  1030.           mov      cursor_y,1
  1031.           mov      pos_x,1
  1032.           mov      pos_y,2
  1033.           GOTOXY   pos_x,pos_y
  1034.           mov      col_start,1
  1035.           mov      block_top,1
  1036.           mov      block_end,1
  1037.           call     info_win
  1038.           mov      char,f10
  1039.           ret
  1040. new_act   endp
  1041.  
  1042. edit_win  proc     near                 ;+------+
  1043.           push     di                   ;| Edit |
  1044.           push     es                   ;+------+
  1045.           push     ax
  1046.           push     cx
  1047.           pushf
  1048.  
  1049.           mov      es,monitor
  1050.           mov      cx,6                 ;[Edit] be reversed
  1051.           mov      di,25
  1052.           mov      al,reverse1
  1053.   e_6:    mov      es:[di],al
  1054.           add      di,2
  1055.           loop     e_6
  1056.  
  1057.   get_e:  GET_CHAR
  1058.           call     l_or_r
  1059.           cmp      al,0
  1060.           jne      end_e
  1061.           cmp      char,f10
  1062.           je       end_e
  1063.           cmp      char,enter_s
  1064.           jne      get_e
  1065.           mov      char,f10
  1066.  
  1067.   end_e:  popf
  1068.           pop      cx
  1069.           pop      ax
  1070.           pop      es
  1071.           pop      di
  1072.           ret
  1073. edit_win  endp
  1074.  
  1075. utl_win   proc     near                 ;+---------+
  1076.           push     ax                   ;| Utility |
  1077.           push     bx                   ;+---------+
  1078.           push     cx
  1079.           push     es
  1080.           push     si
  1081.           push     di
  1082.  
  1083.           cld
  1084.           mov      es,monitor
  1085.           mov      cx,9                 ;[Utility] be reversed
  1086.           mov      di,43
  1087.           mov      al,reverse1
  1088.   u_9:    mov      es:[di],al
  1089.           add      di,2
  1090.           loop     u_9
  1091.  
  1092.   draw_u: mov      si,offset win_utl+3 ;Draw File Window
  1093.           xor      cx,cx
  1094.           mov      cl,win_utl+1
  1095.           xor      bx,bx
  1096.   loopu2: mov      di,y_table[bx+2]
  1097.           add      bx,2
  1098.           add      di,40
  1099.           push     cx
  1100.           pushf
  1101.           xor      cx,cx
  1102.           mov      al,win_utl+2
  1103.           mov      cl,win_utl
  1104.   loopu1: movsb
  1105.           stosb
  1106.           loop     loopu1
  1107.  
  1108.           popf
  1109.           pop      cx
  1110.           loop     loopu2
  1111.  
  1112.           mov      bx,win_y             ;Mark Selection
  1113.           shl      bx,1
  1114.           mov      di,y_table[bx+2]
  1115.           add      di,43
  1116.           xor      cx,cx
  1117.           mov      cl,win_utl
  1118.           sub      cl,2
  1119.           mov      al,reverse3
  1120.   rev_u:  mov      es:[di],al
  1121.           add      di,2
  1122.           loop     rev_u
  1123.  
  1124.   get_u:  GET_CHAR
  1125.           call     l_or_r
  1126.           cmp      al,0
  1127.           je       _y_
  1128.           jmp      end_u
  1129.   _y_:    mov      ax,utl_max
  1130.           push     ax                   ;If Up or Down
  1131.           call     u_or_d
  1132.           cmp      al,0
  1133.           je       key_u
  1134.           jmp      draw_u
  1135.  
  1136.   key_u:  cmp      char,f10             ;F10
  1137.           je       end_u
  1138.           jne      u_f10
  1139.           jmp      end_u
  1140.   u_f10:  cmp      char,escape          ;ESC
  1141.           jne      nextu1
  1142.           mov      char,f10
  1143.           jmp      end_u
  1144.  
  1145.   nextu1: cmp      char,enter_s
  1146.           je       chk_yu
  1147.           jmp      get_u
  1148.  
  1149.   chk_yu: cmp      win_y,1              ;HELP
  1150.           jne      chk_u2
  1151.           call     help_win
  1152.           jmp      end_u
  1153.  
  1154.   chk_u2: cmp      win_y,2              ;Change Drive
  1155.           jne      chk_u3
  1156.           CURSOR_1
  1157.           call     chg_drive
  1158.           mov      char,f10
  1159.           jmp      end_u
  1160.  
  1161.   CHK_u3: cmp      win_y,3
  1162.           jne      chk_u4
  1163.           mov      char,f10
  1164.           jmp      end_u
  1165.  
  1166.   chk_u4: cmp      win_y,4              ;Print
  1167.           jne      chk_u5
  1168.           mov      ax,1
  1169.           push     ax
  1170.           mov      ax,total_l
  1171.           push     ax
  1172.           call     print_act
  1173.           mov      char,f10
  1174.           jmp      end_u
  1175.  
  1176.   chk_u5:                               ;Lock Terminal
  1177.           mov      char,f10
  1178.           jmp      end_u
  1179.  
  1180.   end_u:  pop      di
  1181.           pop      si
  1182.           pop      es
  1183.           pop      cx
  1184.           pop      bx
  1185.           pop      ax
  1186.           ret
  1187. utl_win   endp
  1188.  
  1189. block_win proc     near                 ;+-------+
  1190.           push     ax                   ;| Block |
  1191.           push     bx                   ;+-------+
  1192.           push     cx
  1193.           push     es
  1194.           push     si
  1195.           push     di
  1196.  
  1197.           cld
  1198.           mov      es,monitor
  1199.           mov      cx,7                 ;[Block] be reversed
  1200.           mov      di,67
  1201.           mov      al,reverse1
  1202.   b_7:    mov      es:[di],al
  1203.           add      di,2
  1204.           loop     b_7
  1205.  
  1206.   draw_b: mov      si,offset win_block+3 ;Draw File Window
  1207.           xor      cx,cx
  1208.           mov      cl,win_block+1
  1209.           xor      bx,bx
  1210.   loopb2: mov      di,y_table[bx+2]
  1211.           add      bx,2
  1212.           add      di,64
  1213.           push     cx
  1214.           pushf
  1215.           xor      cx,cx
  1216.           mov      al,win_block+2
  1217.           mov      cl,win_block
  1218.   loopb1: movsb
  1219.           stosb
  1220.           loop     loopb1
  1221.  
  1222.           popf
  1223.           pop      cx
  1224.           loop     loopb2
  1225.  
  1226.           mov      bx,win_y             ;Mark Selection
  1227.           shl      bx,1
  1228.           mov      di,y_table[bx+2]
  1229.           add      di,67
  1230.           xor      cx,cx
  1231.           mov      cl,win_block
  1232.           sub      cl,2
  1233.           mov      al,reverse3
  1234.   rev_b:  mov      es:[di],al
  1235.           add      di,2
  1236.           loop     rev_b
  1237.  
  1238.   get_b:  GET_CHAR
  1239.           call     l_or_r
  1240.           cmp      al,0
  1241.           jne      end_b
  1242.           mov      ax,block_max
  1243.           push     ax                   ;If Up or Down
  1244.           call     u_or_d
  1245.           cmp      al,0
  1246.           je       key_b
  1247.           jmp      draw_b
  1248.   key_b:  cmp      char,f10
  1249.           je       end_b
  1250.           jmp      get_b
  1251.  
  1252.   end_b:  pop      di
  1253.           pop      si
  1254.           pop      es
  1255.           pop      cx
  1256.           pop      bx
  1257.           pop      ax
  1258.  
  1259.           ret
  1260. block_win endp
  1261.  
  1262. l_or_r    proc     near                 ;Right or Left Key <- ->
  1263.           mov      al,0                 ;Set a Boolean AL=0
  1264.           cmp      char,left
  1265.           jne      next1
  1266.           cmp      win_x,1
  1267.           ja       x_min
  1268.           mov      win_x,win_max+1
  1269.   x_min:  dec      win_x
  1270.           mov      al,1
  1271.   next1:  cmp      char,right
  1272.           jne      next2
  1273.           cmp      win_x,win_max
  1274.           jb       x_max
  1275.           mov      win_x,0
  1276.   x_max:  inc      win_x
  1277.           mov      al,1                 ;Right or Left is True
  1278.   next2:  ret
  1279. l_or_r    endp
  1280.  
  1281. u_or_d    proc     near                 ;Up or Down Key
  1282.           push     bp
  1283.           mov      bp,sp
  1284.           push     dx
  1285.           mov      dx,[bp+4]
  1286.           mov      al,0                 ;Set a Boolean AL=0
  1287.           cmp      char,up
  1288.           jne      nextv1
  1289.           cmp      win_y,1
  1290.           ja       y_min
  1291.           mov      win_y,dx
  1292.           inc      win_y
  1293.   y_min:  dec      win_y
  1294.           mov      al,1                 ;Up or Down is True
  1295.   nextv1: cmp      char,down
  1296.           jne      nextv2
  1297.           cmp      win_y,dx
  1298.           jb       y_max
  1299.           mov      win_y,0
  1300.   y_max:  inc      win_y
  1301.           mov      al,1                 ;Up or Down is True
  1302.  
  1303.   nextv2: pop      dx
  1304.           pop      bp
  1305.           ret      2
  1306. u_or_d    endp
  1307.  
  1308. itoa_5    proc     near                 ;Stack Put Addr. of Data
  1309.           push     bp                   ;Stack Put Value of Data
  1310.           mov      bp,sp
  1311.           push     ax
  1312.           push     bx
  1313.           push     cx
  1314.           push     dx
  1315.           push     si
  1316.           push     di
  1317.           push     es
  1318.           pushf
  1319.  
  1320.           std
  1321.           mov      ax,ds
  1322.           mov      es,ax
  1323.           mov      si,[bp+6]
  1324.           mov      dl,' '
  1325.           mov      [si],dl
  1326.           mov      [si+1],dl
  1327.           mov      [si+2],dl
  1328.           mov      [si+3],dl
  1329.           mov      [si+4],dl
  1330.           mov      ax,[bp+4]
  1331.           mov      bx,10
  1332.   loopd5: mov      si,[bp+6]
  1333.           add      si,3
  1334.           mov      di,si
  1335.           inc      di
  1336.           mov      dx,0
  1337.           div      bx
  1338.           add      dl,30h
  1339.           mov      cx,4
  1340.   rep     movsb
  1341.           mov      [si+1],dl
  1342.           cmp      ax,0
  1343.           jne      loopd5
  1344.  
  1345.           popf
  1346.           pop      es
  1347.           pop      di
  1348.           pop      si
  1349.           pop      dx
  1350.           pop      cx
  1351.           pop      bx
  1352.           pop      ax
  1353.           pop      bp
  1354.           ret      4
  1355. itoa_5    endp
  1356.  
  1357. itoa_3    proc     near
  1358.           push     ax
  1359.           push     bx
  1360.           push     cx
  1361.           push     dx
  1362.           push     si
  1363.           pushf
  1364.  
  1365.           mov      si,offset str_x
  1366.           mov      str_x,' '
  1367.           mov      str_x[1],' '
  1368.           mov      str_x[2],' '
  1369.           mov      ax,cursor_x
  1370.           mov      bx,10
  1371.   loopd3: mov      dx,0
  1372.           div      bx
  1373.           add      dl,30h
  1374.           mov      cl,[si+1]
  1375.           mov      [si+2],cl
  1376.           mov      cl,[si]
  1377.           mov      [si+1],cl
  1378.           mov      [si],dl
  1379.           cmp      ax,0
  1380.           jne      loopd3
  1381.  
  1382.           popf
  1383.           pop      si
  1384.           pop      dx
  1385.           pop      cx
  1386.           pop      bx
  1387.           pop      ax
  1388.           ret
  1389. itoa_3    endp
  1390.  
  1391. extra_del proc     near                 ;Add 2 Lines to be 1 Line
  1392.           mov      es,p_ptr
  1393.           mov      ax,es:[0]
  1394.           mov      q_ptr,ax
  1395.           mov      ax,p_ptr
  1396.           mov      r_ptr,ax
  1397.           cld
  1398.           xor      cx,cx
  1399.           mov      cl,line_buf
  1400.           inc      cx
  1401.           mov      ax,seg sub_line
  1402.           mov      es,ax
  1403.           mov      di,offset sub_line
  1404.           mov      si,offset line_buf
  1405.   rep     movsb                         ;Sub_line = Line_buf
  1406.           mov      cl,line_buf
  1407.           inc      cx
  1408.           neg      cx
  1409.           add      cx,cursor_x
  1410.           cmp      cx,0
  1411.           je       no_20h
  1412.   _fill:  mov      byte ptr [di],' '
  1413.           inc      di
  1414.           loop     _fill
  1415.  
  1416.   no_20h: mov      es,p_ptr             ;Move Next Line UP
  1417.           mov      ax,es:[0]
  1418.           mov      p_ptr,ax
  1419.           call     put_buff
  1420.           xor      cx,cx
  1421.           mov      cl,line_buf
  1422.           cmp      cx,0
  1423.           je       del_nx
  1424.           mov      ax,offset sub_line+1
  1425.           mov      bx,di
  1426.           sub      bx,ax
  1427.           mov      ax,bx
  1428.           add      bx,cx
  1429.           cmp      bx,255
  1430.           jbe      ad_sub
  1431.           neg      ax
  1432.           add      ax,255
  1433.           mov      cx,ax
  1434.   ad_sub: mov      si,offset line_buf+1
  1435.           mov      ax,seg sub_line
  1436.           mov      es,ax
  1437.           cld
  1438.   rep     movsb
  1439.           mov      bx,offset sub_line+1
  1440.           mov      cx,di
  1441.           sub      cx,bx
  1442.           mov      line_buf,cl
  1443.           mov      ax,seg line_buf
  1444.           mov      es,ax
  1445.           mov      di,offset line_buf+1
  1446.           mov      si,offset sub_line+1
  1447.           cld
  1448.   rep     movsb
  1449.           mov      ax,r_ptr
  1450.           mov      p_ptr,ax
  1451.           call     get_buff
  1452.  
  1453.   del_nx: mov      es,q_ptr
  1454.           push     es
  1455.           mov      ax,es:[0]
  1456.           mov      es,r_ptr
  1457.           mov      es:[0],ax
  1458.           pop      es
  1459.           xor      cx,cx
  1460.           mov      cl,es:[2]
  1461.           FREE_    q_ptr
  1462.           cmp      cx,0
  1463.           je       extr_z
  1464.  
  1465.   dis_2:  mov      ax,es:[30]
  1466.           mov      es,ax
  1467.           FREE_    ax
  1468.           loop     dis_2
  1469.  
  1470.   extr_z: dec      total_l
  1471.           mov      ax,cursor_y
  1472.           cmp      ax,block_top
  1473.           jb       bk_1e
  1474.           cmp      ax,block_end
  1475.           jb       bk_2e
  1476.           jmp      bk_ze
  1477.   bk_1e:  dec      block_top
  1478.   bk_2e:  dec      block_end
  1479.   bk_ze:  call     info_win
  1480.           call     refresh_
  1481.           ret
  1482. extra_del endp
  1483.  
  1484. s_c_key   proc     near
  1485.           cmp      scan_key,n_key       ;[N/n] pressed
  1486.           jne      s_c_1
  1487.           call     ins_line
  1488.           jmp      s_c_z
  1489.  
  1490.   s_c_1:  cmp      scan_key,y_key       ;[Y/y] pressed
  1491.           jne      s_c_2
  1492.           mov      ax,cursor_y
  1493.           cmp      ax,block_top
  1494.           jb       bk_1d
  1495.           cmp      ax,block_end
  1496.           jb       bk_2d
  1497.           jmp      bk_zd
  1498.   bk_1d:  dec      block_top
  1499.   bk_2d:  dec      block_end
  1500.   bk_zd:  call     del_line
  1501.           jmp      s_c_z
  1502.  
  1503.   s_c_2:  cmp      scan_key,b_key       ;[B/b] pressed
  1504.           jne      s_c_3
  1505.           mov      ax,cursor_y
  1506.           mov      block_top,ax
  1507.           call     refresh_
  1508.           jmp      s_c_z
  1509.  
  1510.   s_c_3:  cmp      scan_key,k_key       ;[K/k] pressed
  1511.           jne      s_c_4
  1512.           mov      ax,cursor_y
  1513.           mov      block_end,ax
  1514.           call     refresh_
  1515.           jmp      s_c_z
  1516.  
  1517.   s_c_4:  cmp      scan_key,h_key       ;[H/h] pressed
  1518.           jne      s_c_5
  1519.           mov      ax,block_top
  1520.           mov      block_end,ax
  1521.           call     refresh_
  1522.           jmp      s_c_z
  1523.  
  1524.   s_c_5:  cmp      scan_key,m_key      ;[M/m] pressed
  1525.           jne      s_c_6
  1526.           mov      cx,block_end
  1527.           cmp      cx,block_top
  1528.           jbe      no_m_
  1529.           cmp      cx,cursor_y
  1530.           jae      m_1_
  1531.           mov      pos_y,2
  1532.           GOTOXY   pos_x,pos_y
  1533.           call     ptr_move
  1534.           sub      cx,block_top
  1535.           sub      cursor_y,cx
  1536.           mov      ax,cursor_y
  1537.           mov      block_top,ax
  1538.           add      ax,cx
  1539.           mov      block_end,ax
  1540.           call     refresh_
  1541.           jmp      s_c_z
  1542.  
  1543.   m_1_:   mov      ax,block_top
  1544.           cmp      ax,cursor_y
  1545.           jbe      no_m_
  1546.           call     ptr_move
  1547.           mov      ax,cursor_y
  1548.           sub      cx,block_top
  1549.           mov      block_top,ax
  1550.           mov      block_end,ax
  1551.           add      block_end,cx
  1552.           call     refresh_
  1553.   no_m_:  jmp      s_c_z
  1554.  
  1555.   s_c_6:  cmp      scan_key,o_key      ;[O/o] pressed
  1556.           je       _6_ok
  1557.           jmp      s_c_7
  1558.   _6_ok:  mov      cx,block_end
  1559.           cmp      cx,block_top
  1560.           jbe      chk_no
  1561.           mov      ax,cursor_y
  1562.           cmp      ax,block_top
  1563.           jb       yes_c_
  1564.           cmp      ax,block_end
  1565.           jae      yes_c_
  1566.   chk_no: jmp      no_c_
  1567.  
  1568.   yes_c_: push     ax
  1569.           call     find_ptr
  1570.           mov      ax,p_ptr
  1571.           mov      p_lin,ax
  1572.           mov      ax,r_ptr
  1573.           mov      es,ax
  1574.           mov      bx,block_top
  1575.           push     bx
  1576.           call     find_ptr
  1577.           call     put_buff
  1578.           mov      bx,p_ptr
  1579.           NEW_
  1580.           mov      es:[0],ax
  1581.           push     es
  1582.           mov      es,ax
  1583.           mov      byte ptr es:[2],0
  1584.           mov      word ptr es:[30],0
  1585.           pop      es
  1586.           mov      p_ptr,ax
  1587.           call     get_buff
  1588.           sub      cx,block_top
  1589.           push     cx
  1590.           dec      cx
  1591.           cmp      cx,0
  1592.           je       cpy_z
  1593.  
  1594.   r_cpy:  push     es
  1595.           mov      es,bx
  1596.           mov      bx,es:[0]
  1597.           mov      p_ptr,bx
  1598.           pop      es
  1599.           call     put_buff
  1600.           mov      es,es:[0]
  1601.           NEW_
  1602.           mov      es:[0],ax
  1603.           push     es
  1604.           mov      es,ax
  1605.           mov      byte ptr es:[2],0
  1606.           mov      word ptr es:[30],0
  1607.           pop      es
  1608.           mov      p_ptr,ax
  1609.           call     get_buff
  1610.           loop     r_cpy
  1611.  
  1612.   cpy_z:  pop      cx
  1613.           mov      es,p_ptr
  1614.           mov      ax,p_lin
  1615.           mov      es:[0],ax
  1616.           mov      ax,cursor_y
  1617.           mov      block_top,ax
  1618.           mov      block_end,ax
  1619.           add      block_end,cx
  1620.           add      total_l,cx
  1621.           call     refresh_
  1622.           call     info_win
  1623.   no_c_:  jmp      s_c_z
  1624.  
  1625.   s_c_7:  cmp      scan_key,d_key      ;[D/d] pressed
  1626.           jne      s_c_8
  1627.           mov      cx,block_end
  1628.           cmp      cx,block_top
  1629.           jbe      no_d_
  1630.           sub      cx,block_top
  1631.           mov      pos_y,2
  1632.           GOTOXY   pos_x,pos_y
  1633.           mov      ax,block_top
  1634.           mov      block_end,ax
  1635.  
  1636.   d_blk:  mov      cursor_y,ax
  1637.           call     del_line
  1638.           loop     d_blk
  1639.  
  1640.   no_d_:  jmp      s_c_z
  1641.  
  1642.   s_c_8:  cmp      scan_key,p_key      ;[P/p] pressed
  1643.           jne      s_c_z
  1644.           mov      cx,block_top
  1645.           cmp      cx,block_end
  1646.           jae      s_c_z
  1647.           push     cx
  1648.           mov      ax,block_end
  1649.           sub      ax,cx
  1650.           push     ax
  1651.           call     print_act
  1652.           call     refresh_
  1653.   s_c_z:
  1654.           ret
  1655. s_c_key   endp
  1656.  
  1657. ptr_move  proc     near
  1658.           mov      ax,block_top
  1659.           push     ax
  1660.           call     find_ptr
  1661.           mov      es,r_ptr             ;ES
  1662.           mov      ax,p_ptr             ;P_lin
  1663.           mov      p_lin,ax
  1664.           mov      ax,block_end
  1665.           push     ax
  1666.           call     find_ptr
  1667.           mov      bx,r_ptr             ;BX
  1668.           mov      ax,p_ptr             ;Q_lin
  1669.           mov      q_lin,ax
  1670.           mov      ax,cursor_y
  1671.           push     ax
  1672.           call     find_ptr             ;R_ptr
  1673.                                         ;P_ptr
  1674.           mov      ax,q_lin
  1675.           mov      es:[0],ax
  1676.           mov      es,bx
  1677.           mov      ax,p_ptr
  1678.           mov      es:[0],ax
  1679.           mov      es,r_ptr
  1680.           mov      ax,p_lin
  1681.           mov      es:[0],ax
  1682.           ret
  1683. ptr_move  endp
  1684.  
  1685. show_name proc     near
  1686.           push     es
  1687.           push     si
  1688.           push     di
  1689.           mov      es,monitor
  1690.           mov      di,y_table[48]
  1691.           mov      si,offset this_dir[1]
  1692.           mov      al,0eh
  1693.           mov      cl,this_dir
  1694.           xor      ch,ch
  1695.   lll:    movsb
  1696.           stosb
  1697.           loop     lll
  1698.  
  1699.           mov      cl,this_dir
  1700.           neg      cx
  1701.           add      cx,80
  1702.   clr_el: mov      byte ptr es:[di],' '
  1703.           mov      byte ptr es:[di+1],0eh
  1704.           add      di,2
  1705.           loop     clr_el
  1706.  
  1707.           pop      di
  1708.           pop      si
  1709.           pop      es
  1710.           ret
  1711. show_name endp
  1712.  
  1713. here_dir  proc     near
  1714.           mov      ah,19h                 ;GET Current Drive
  1715.           int      21h
  1716.           add      al,65
  1717.           mov      this_dir[1],al
  1718.           mov      this_dir[2],':'
  1719.           mov      this_dir[3],'\'
  1720.           mov      si,offset this_dir[4] ;GET Current Directory
  1721.           mov      dl,0
  1722.           mov      ah,47h
  1723.           int      21h
  1724.           mov      al,0
  1725.           mov      cx,64
  1726.           mov      di,offset this_dir[1]
  1727.   cpr_0:  cmp      byte ptr [di],0
  1728.           je       __dir
  1729.           inc      al
  1730.           inc      di
  1731.           loop     cpr_0
  1732.  
  1733.   __dir:  cmp      al,3
  1734.           jne      slash_
  1735.           dec      al
  1736.           dec      di
  1737.   slash_: add      al,13
  1738.           mov      this_dir,al
  1739.           mov      byte ptr [di],'\'
  1740.           inc      di
  1741.           mov      cx,13
  1742.           mov      ax,seg this_dir
  1743.           mov      es,ax
  1744.           mov      si,offset file_name
  1745.   rep     movsb
  1746.           call     show_name
  1747.           ret
  1748. here_dir  endp
  1749.  
  1750. read_line proc     near                 ;Stack Put [Offset of Line]
  1751.           push     bp                   ;DL put X-axis
  1752.           mov      bp,sp                ;DH put Y-axis
  1753.           push     ax
  1754.           push     bx
  1755.           push     si
  1756.           push     di
  1757.           push     es
  1758.           xor      bx,0
  1759.           dec      dh
  1760.           sub      dl,2
  1761.           mov      bl,dh
  1762.           shl      bx,1
  1763.           mov      es,monitor
  1764.           mov      si,y_table[bx]
  1765.           mov      bl,dl
  1766.           shl      bl,1
  1767.           inc      dl
  1768.           add      si,bx
  1769.           mov      cl,0
  1770.           mov      di,[bp+4]
  1771.           mov      bl,[di]
  1772.           add      dl,bl
  1773.  
  1774.   re_in:  mov      ah,2
  1775.           int      10h
  1776.  
  1777.           xor      ch,ch
  1778.           mov      cl,bl
  1779.           cmp      cx,0
  1780.           je       no_c
  1781.   _one_c: add      si,2
  1782.           inc      di
  1783.           mov      al,[di]
  1784.           mov      es:[si],al
  1785.           loop     _one_c
  1786.    no_c:  mov      byte ptr es:[si+2],' '
  1787.           mov      byte ptr [di+1],0
  1788.           sub      di,bx
  1789.           mov      byte ptr [di],bl
  1790.           sub      si,bx
  1791.           sub      si,bx
  1792.  
  1793.           GET_KEY
  1794.           cmp      ascii_key,0
  1795.           je       re_in
  1796.           cmp      ascii_key,backspace
  1797.           jne      rk1
  1798.           cmp      bl,0
  1799.           je       re_in
  1800.           dec      bx
  1801.           dec      dl
  1802.           jmp      re_in
  1803.  
  1804.   rk1:    cmp      ascii_key,enter_a
  1805.           jne      rk2
  1806.           mov      cl,1
  1807.           jmp      out_rk
  1808.  
  1809.   rk2:    cmp      ascii_key,escape_a
  1810.           jne      rk3
  1811.           mov      cl,0
  1812.           jmp      out_rk
  1813.  
  1814.   rk3:    cmp      bl,28
  1815.           je       re_in
  1816.           inc      dl
  1817.           inc      bx
  1818.           mov      al,ascii_key
  1819.           mov      [di+bx],al
  1820.           jmp      re_in
  1821.  
  1822.   out_rk: pop      es
  1823.           pop      di
  1824.           pop      si
  1825.           pop      bx
  1826.           pop      ax
  1827.           pop      bp
  1828.           ret      2
  1829. read_line endp
  1830.  
  1831. code      ends
  1832. ;--------------------------------------
  1833. stack     segment  stack
  1834.           db       2048 dup(?)
  1835. stack     ends
  1836.           end      start
  1837.